package com.bw.liuyushan.liuyushan20210929.MVP.Presenter;

import com.bw.liuyushan.liuyushan20210929.Entity.JsonBean;
import com.bw.liuyushan.liuyushan20210929.Entity.UserBean;
import com.bw.liuyushan.liuyushan20210929.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.mvp_lib.Presenter.BasePresenter;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * Liuyushan20210929
 * file name is : BasePresenterTest
 * created by Ender on 2021/9/29 13:49.
 * author : 刘雨杉
 * Describe:
 */
public class BasePresenterTest extends BasePresenter<IContrackTest.C_ModelTest, IContrackTest.C_ViewTest> {
    Disposable disposable;//RxJava防止内存泄露
    public BasePresenterTest(IContrackTest.C_ModelTest mModel, IContrackTest.C_ViewTest mView) {
        super(mModel, mView);
    }
    public void mpLogin(String username, String password){
        mModel.askLogin(username, password, new Observer<UserBean>() {
            @Override
            public void onSubscribe(Disposable d) {
                disposable = d;//RxJava防止内存泄露
            }

            @Override
            public void onNext(UserBean userBean) {
                mView.ShowLogin(userBean);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }
    public void mpReg(String username, String password, String repassword){
        mModel.askReg(username, password, repassword, new Observer<UserBean>() {
            @Override
            public void onSubscribe(Disposable d) {
                disposable = d;//RxJava防止内存泄露
            }

            @Override
            public void onNext(UserBean userBean) {
                mView.ShowReg(userBean);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }
    public void mpDate(String url){
        mModel.askDate(url, new Observer<JsonBean>() {
            @Override
            public void onSubscribe(Disposable d) {
                disposable = d;//RxJava防止内存泄露
            }

            @Override
            public void onNext(JsonBean jsonBean) {
                mView.ShowDate(jsonBean);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
